#!/usr/bin/env python

from mxit import commands
from mxit import handles

class listener:

   def __init__(self,blend):
      self.blend = blend;

   # Data has been sent to MXit
   def nudge(self,command):
      self.blend.logger.info("nudge");
      if self.blend.autoAway:
         if self.blend.currentlyConnected:
            if command == commands.Client.PRESENCE:
               self.blend.autoAway.status();
            else:
               self.blend.autoAway.poke();

   # Disconnected
   def status_changed(self,status,reason):
      if status == handles.Status.DISCONNECTED:
         if self.blend.autoAway:
            self.blend.autoAway.stopCaring();
      elif status == handles.Status.ACTIVE:
         if self.blend.autoAway:
            self.blend.autoAway.startCaring();